load("@rules_proto_grpc//python:defs.bzl", "python_grpc_library")
load("@rules_python//python:defs.bzl", "py_library")
load("@pip_deps//:requirements.bzl", "requirement")

package(
    default_testonly = 1,
    default_visibility = ["//visibility:public"],
)

licenses(["notice"])

python_grpc_library(
    name = "testing_api_python_library",
    protos = ["//proto:testing_api_proto"],
)

py_library(
    name = "_primitives",
    srcs = ["_primitives.py"],
    srcs_version = "PY3",
    deps = [
        ":testing_api_python_library",
        "@com_google_protobuf//:protobuf_python",
        "@tink_py//tink:tink_python",
        "@tink_py//tink/aead",
        "@tink_py//tink/daead",
        "@tink_py//tink/hybrid",
        "@tink_py//tink/jwt",
        "@tink_py//tink/mac",
        "@tink_py//tink/prf",
        "@tink_py//tink/signature",
        "@tink_py//tink/streaming_aead",
        requirement("absl-py"),
    ],
)

py_test(
    name = "_primitives_test",
    srcs = ["_primitives_test.py"],
    python_version = "PY3",
    srcs_version = "PY3",
    deps = [
        ":_primitives",
        requirement("absl-py"),
        ":testing_api_python_library",
        "@tink_py//tink/jwt",
    ],
)

py_library(
    name = "testing_servers",
    srcs = ["testing_servers.py"],
    data = [
        "//testdata/aws:credentials",
        "//testdata/gcp:credentials",
    ],
    srcs_version = "PY3",
    deps = [
        ":_primitives",
        ":key_util",
        ":testing_api_python_library",
        "@com_google_protobuf//:protobuf_python",
        "@tink_py//tink:tink_python",
        "@tink_py//tink/proto:tink_py_pb2",
        requirement("absl-py"),
        "@org_python_pypi_portpicker//:portpicker",
    ],
)

py_test(
    name = "testing_servers_test",
    srcs = ["testing_servers_test.py"],
    data = [
        ":testing_servers",
    ],
    python_version = "PY3",
    srcs_version = "PY3",
    deps = [
        ":testing_api_python_library",
        requirement("absl-py"),
        "//util/test_keys",
        "@org_python_pypi_portpicker//:portpicker",
        "@tink_py//tink/aead",
        "@tink_py//tink/daead",
        "@tink_py//tink/hybrid",
        "@tink_py//tink/jwt",
        "@tink_py//tink/mac",
        "@tink_py//tink/prf",
        "@tink_py//tink/proto:common_py_pb2",
        "@tink_py//tink/proto:jwt_ecdsa_py_pb2",
        "@tink_py//tink/proto:jwt_hmac_py_pb2",
        "@tink_py//tink/proto:tink_py_pb2",
        "@tink_py//tink/signature",
        "@tink_py//tink/streaming_aead",
    ],
)

py_library(
    name = "key_util",
    srcs = ["key_util.py"],
    srcs_version = "PY3",
    deps = [
        "@com_google_protobuf//:protobuf_python",
        "@tink_py//tink/proto:aes_cmac_prf_py_pb2",
        "@tink_py//tink/proto:aes_cmac_py_pb2",
        "@tink_py//tink/proto:aes_ctr_hmac_aead_py_pb2",
        "@tink_py//tink/proto:aes_ctr_hmac_streaming_py_pb2",
        "@tink_py//tink/proto:aes_eax_py_pb2",
        "@tink_py//tink/proto:aes_gcm_hkdf_streaming_py_pb2",
        "@tink_py//tink/proto:aes_gcm_py_pb2",
        "@tink_py//tink/proto:aes_gcm_siv_py_pb2",
        "@tink_py//tink/proto:aes_siv_py_pb2",
        "@tink_py//tink/proto:chacha20_poly1305_py_pb2",
        "@tink_py//tink/proto:ecdsa_py_pb2",
        "@tink_py//tink/proto:ecies_aead_hkdf_py_pb2",
        "@tink_py//tink/proto:ed25519_py_pb2",
        "@tink_py//tink/proto:hkdf_prf_py_pb2",
        "@tink_py//tink/proto:hmac_prf_py_pb2",
        "@tink_py//tink/proto:hmac_py_pb2",
        "@tink_py//tink/proto:hpke_py_pb2",
        "@tink_py//tink/proto:jwt_ecdsa_py_pb2",
        "@tink_py//tink/proto:jwt_hmac_py_pb2",
        "@tink_py//tink/proto:jwt_rsa_ssa_pkcs1_py_pb2",
        "@tink_py//tink/proto:jwt_rsa_ssa_pss_py_pb2",
        "@tink_py//tink/proto:kms_aead_py_pb2",
        "@tink_py//tink/proto:kms_envelope_py_pb2",
        "@tink_py//tink/proto:rsa_ssa_pkcs1_py_pb2",
        "@tink_py//tink/proto:rsa_ssa_pss_py_pb2",
        "@tink_py//tink/proto:xchacha20_poly1305_py_pb2",
    ],
)

py_test(
    name = "key_util_test",
    srcs = ["key_util_test.py"],
    python_version = "PY3",
    srcs_version = "PY3",
    deps = [
        ":key_util",
        "@com_google_protobuf//:protobuf_python",
        requirement("absl-py"),
        "@tink_py//tink/proto:tink_py_pb2",
    ],
)

py_library(
    name = "utilities",
    srcs = ["utilities.py"],
    deps = [
        "//tink_config",
        "@tink_py//tink/aead",
        "@tink_py//tink/daead",
        "@tink_py//tink/hybrid",
        "@tink_py//tink/jwt",
        "@tink_py//tink/mac",
        "@tink_py//tink/prf",
        "@tink_py//tink/proto:common_py_pb2",
        "@tink_py//tink/proto:tink_py_pb2",
        "@tink_py//tink/signature",
        "@tink_py//tink/streaming_aead",
    ],
)

py_test(
    name = "utilities_test",
    srcs = ["utilities_test.py"],
    deps = [
        ":utilities",
        "//tink_config",
        "//util/test_keys",
        "@tink_py//tink/aead",
        "@tink_py//tink/mac",
        "@tink_py//tink/proto:tink_py_pb2",
        requirement("absl-py"),
    ],
)
